package com.authine.cloudpivot.ext.enums.goods;

import java.util.HashMap;

/**
 * @Author: zhoujian
 * @Date: 2019/7/5 22:58
 * @Version 1.0
 */
public enum MallSortEnum {

    PRICE_LOW_HIGH("pretax_price ASC", "价格升序"),
    PRICE_HIGH_LOW("pretax_price DESC", "价格降序"),
    LAST_HIGH_LOW("modifiedTime DESC", "最后修改时间降序"),
    ID_HIGH_LOW("id DESC", "id降序");

    private static final HashMap<Integer, MallSortEnum> idOf = new HashMap<>(MallSortEnum.values().length);

    static {
        for (MallSortEnum e : MallSortEnum.values()) {
            idOf.put(e.ordinal(), e);
        }
    }

    public String sql;
    public String text;

    MallSortEnum(String sql, String text) {
        this.sql = sql;
        this.text = text;
    }

    public static MallSortEnum idOf(Integer id) {
        return idOf.getOrDefault(id, ID_HIGH_LOW);
    }

    @Override
    public String toString() {
        return text;
    }
}
